package 创建型设计模式.原型模式.demo;

/**
 * 深拷贝
 * @Author lf
 * @Date 3/29/2024
 */
public class DeepPrototype implements Prototype {
    private ComplexObject complexObject;

    public DeepPrototype(ComplexObject complexObject) {
        this.complexObject = complexObject;
    }

    // 深拷贝
    @Override
    public Prototype clone() throws CloneNotSupportedException {
        ComplexObject coNew = new ComplexObject(complexObject.getProperty());
        return new DeepPrototype(coNew);
    }
}
